package servlet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author liwq 719812998@qq.com
 * @date 2017/10/25
 * @comment
 */
public class IndexServlet extends HttpServlet {

    private final Logger logger = LoggerFactory.getLogger(IndexServlet.class);

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doGet(req, resp);

//        req.getRequestDispatcher("/article/index.jsp").forward(req, resp);//转发

        resp.setCharacterEncoding("utf-8");//
        req.setCharacterEncoding("utf-8");

        resp.setContentType("text/html");
        logger.info("===> 重定向到 [ /article/index.jsp ]");
        resp.sendRedirect("/article/index.jsp");//重定向
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        super.doPost(req, resp);
    }
}
